﻿using DFGK_WMS.IRepository;
using DFGK_WMS.Repository;
using DFGK_WMS.WebAPI.Controllers.Result;
using Microsoft.AspNetCore.Mvc;

namespace DFGK_WMS.WebAPI.Controllers.数字孪生
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class DigitalTwinController : ControllerBase
    {
        public IDigitalTwinRepository digitalTwinRepository;

        public DigitalTwinController(IDigitalTwinRepository digitalTwinRepository)
        {
            this.digitalTwinRepository = digitalTwinRepository;
        }


        /// <summary>
        /// 根据仓位编码查询物料信息
        /// </summary>
        /// <param name="CellCode"></param>
        /// <returns></returns>
        [HttpGet]
        public IActionResult GetMaterialsByCell(string CellCode)
        {
            if (CellCode == null )
            {
                return Ok(BaseResult.Result(false, "请求参数有误", "500"));
            }
            var list = digitalTwinRepository.GetMaterialsByCell(CellCode);
            if (list.Count() > 0)
            {
                return Ok(BaseResult.Result(list, "查询成功", "200"));
            }
            return Ok(BaseResult.Result(false, "查询失败", "500"));
        }

        /// <summary>
        /// 出入库每日统计
        /// </summary>
        /// <param name="CellCode"></param>
        /// <returns></returns>
        [HttpGet]
        public IActionResult GetReceivingShippingEverydayQty()
        {
            var list = digitalTwinRepository.GetReceivingShippingEverydayQty();
            if (list != null)
            {
                return Ok(BaseResult.Result(list, "查询成功", "200"));
            }
            return Ok(BaseResult.Result(false, "查询失败", "500"));
        }


        /// <summary>
        /// 出入库统计
        /// </summary>
        /// <param name="CellCode"></param>
        /// <returns></returns>
        [HttpGet]
        public IActionResult GetReceivingShippingQty()
        {
            var list = digitalTwinRepository.GetReceivingShippingQty();
            if (list != null)
            {
                return Ok(BaseResult.Result(list, "查询成功", "200"));
            }
            return Ok(BaseResult.Result(false, "查询失败", "500"));
        }

        /// <summary>
        /// 移库盘库统计
        /// </summary>
        /// <param name="CellCode"></param>
        /// <returns></returns>
        [HttpGet]
        public IActionResult GetStocktakingTransferBinQty()
        {
            var list = digitalTwinRepository.GetStocktakingTransferBinQty();
            if (list != null)
            {
                return Ok(BaseResult.Result(list, "查询成功", "200"));
            }
            return Ok(BaseResult.Result(false, "查询失败", "500"));
        }

        /// <summary>
        /// 获取器材总数
        /// </summary>
        /// <param name="CellCode"></param>
        /// <returns></returns>
        [HttpGet]
        public IActionResult GetMaterialQty()
        {
            var list = digitalTwinRepository.GetMaterialQty();

            return Ok(BaseResult.Result(list, "查询成功", "500"));
        }


        /// <summary>
        /// 出入库每周流程
        /// </summary>
        /// <param name="CellCode"></param>
        /// <returns></returns>
        [HttpGet]
        public IActionResult GetReceivingShippingWeeklyQty()
        {
            var list = digitalTwinRepository.GetReceivingShippingWeeklyQty();
            if (list != null)
            {
                return Ok(BaseResult.Result(list, "查询成功", "200"));
            }
            return Ok(BaseResult.Result(false, "查询失败", "500"));
        }
    }
}
